package com.meilai.project.entity.personnel.onTurn;

import com.baomidou.mybatisplus.annotation.TableName;
import com.meilai.project.core.bean.SuperEntity;
import com.meilai.project.entity.system.UserDepartmentRelation;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author xchen
 * @since 2022-01-26
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("transfer_apply_new_dep")
@ApiModel(value = "TransferApplyNewDep对象", description = "")
public class TransferApplyNewDep extends SuperEntity {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "调岗申请id")
    private Long pid;

    @ApiModelProperty(value = "部门id")
    private Long department_id;

    @ApiModelProperty(value = "部门")
    private String department;

    @ApiModelProperty(value = "职位")
    private String job;

    @ApiModelProperty(value = "是否为主部门")
    private Boolean main;

    @ApiModelProperty(value = "是否为业务负责人")
    private Boolean business_head;


    public static final String PID = "pid";

    public static final String DEPARTMENT_ID = "department_id";

    public static final String JOB = "job";

    public static final String MAIN = "main";

    public static final String BUSINESS_HEAD = "business_head";

    public static UserDepartmentRelation to(Long userId, TransferApplyNewDep dep) {
        UserDepartmentRelation userDepartmentRelation = new UserDepartmentRelation();
        userDepartmentRelation.setUser_id(userId);
        userDepartmentRelation.setDepartment_id(dep.getDepartment_id());
        userDepartmentRelation.setJob(dep.getJob());
        userDepartmentRelation.setMain(dep.getMain());
        userDepartmentRelation.setBusiness_head(dep.getBusiness_head());
        return userDepartmentRelation;
    }

    public static List<UserDepartmentRelation> to(Long userId, List<TransferApplyNewDep> depList) {
        List<UserDepartmentRelation> result = new ArrayList<>();
        for (TransferApplyNewDep transferApplyNewDep : depList) {
            result.add(to(userId, transferApplyNewDep));
        }
        return result;
    }

}
